﻿using IKE.LCAFormat.ILCD.Flow;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Xml.Linq;
using System.Collections.Generic;
using System.IO;
using System.Xml;

namespace IKE.LCAFormatTest
{
    
    
    /// <summary>
    ///This is a test class for FlowDataSetTest and is intended
    ///to contain all FlowDataSetTest Unit Tests
    ///</summary>
    [TestClass()]
    public class FlowDataSetTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Create
        ///</summary>
        [TestMethod()]
        public void CreateTest()
        {
            XDocument doc = XDocument.Load(this.TestContext.TestDir + @"\..\..\IKE.LCAFormat\ILCD\Flow\sample_flow.xml");
            FlowDataSet target = FlowDataSet.Create(doc);

            Assert.AreEqual(
                target.flowInformation.dataSetInformation.UUID,
                new Guid("fe0acd60-3ddc-11dd-af54-0050c2490048"));
            Assert.AreEqual(
                target.flowInformation.dataSetInformation.name.baseName[0].Value,
                "carbon dioxide");
            Assert.AreEqual(
                target.flowInformation.dataSetInformation.classificationInformation.elementaryFlowCategorization[0].category.Count,
                3);
            Assert.AreEqual(
                target.modellingAndValidation.complianceDeclarations.compliance.referenceToComplianceSystem.shortDescription[0].Value,
                "ILCD Data Network compliance");
            Assert.AreEqual(
               target.administrativeInformation.dataEntryBy.referenceToDataSetFormat[0].uri,
               "../sources/ILCD_Format_a97a0155-0234-4b87-b4ce-a45da52f2a40_01.00.000.xml");
            Assert.AreEqual(
              target.flowProperties.flowProperty[0].meanValue,
              1);
        }

        /// <summary>
        ///A test for Save
        ///</summary>
        [TestMethod()]
        public void SaveTest()
        {
            FlowDataSet target = new FlowDataSet(); // TODO: Initialize to an appropriate value
            string xmlFile = @"e:\flowtemp.xml"; // TODO: Initialize to an appropriate value
            target.Save(xmlFile);
           // Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }




    }
}















